package my.edu.model.bills.purchase.entity.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.Valid;
import jakarta.validation.constraints.*;
import jakarta.validation.groups.Default;
import lombok.Data;
import my.edu.common.validate.IntegerPattern;
import my.edu.common.validate.groups.Insert;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;

@Data
public class PurchaseReturnDTO {
    @Null(message = "id必须为空", groups = {Insert.class})
    @NotNull(message = "id不能为空", groups = {Default.class})
    private Long id;
    @NotBlank(message = "编号不能为空", groups = {Default.class})
    private String orderNo;
    @NotNull(message = "日期不能为空", groups = {Insert.class})
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDate orderDate;
    private BigDecimal discountRate;//优惠率
    @Min(value = 0, message = "金额必须大于0", groups = {Insert.class})
    private BigDecimal discountAmount;//退款优惠
    private Integer quantity;//退款数量
    private BigDecimal refundAmount;//退款金额
    @Min(value = 0, message = "金额必须大于0", groups = {Insert.class})
    private BigDecimal amountAfterDiscount;//优惠后金额
    @Min(value = 0, message = "金额必须大于0", groups = {Insert.class})
    private BigDecimal refundedAmount;//已退款金额
    //@Min(value = 0, message = "金额必须大于0", groups = {Insert.class})
    //private BigDecimal refundedAmountWithPayableBalance;//供应商应付抵扣金额
    //private String refundStatus;//退款状态
//    @IntegerPattern(regexp = "^[01]$", message = "审核状态参数错误")
//    private Integer isAudited;//是否审核
    private String remark;//
    private String deliveryMethod;//交货方式
    private Integer sourcePurchaseQuantity;//源购货数量
    @Min(value = 1, message = "账户id必须大于0", groups = {Insert.class})
    private Long settlementAccountId;//结算账户ID
    private String settlementAccountName;//
    private Long logisticsId;//物流ID
    private String logisticsNo;//
    @NotNull(message = "供应商id不能为空", groups = {Insert.class})
    @Min(value = 1, message = "供应商id必须大于0", groups = {Insert.class})
    private Long supplierId;//供应商ID
    private String supplierName;//
    @NotNull(message = "销售人员id不能为空", groups = {Insert.class})
    @Min(value = 1, message = "业务员id必须大于0", groups = {Insert.class})
    private Long salesmanId;//业务员ID
    private String salesmanName;//
    private Long purchaseOrderId;//购货单ID
    private String purchaseOrderNo;//
//    private Long auditorId;//审核人ID
//    private String auditorName;//

    @Valid
    @NotEmpty(message = "采购明细不能为空", groups = {Insert.class})
    private List<PurchaseReturnDetailOrderDTO> purchaseReturnDetailDTOList;
    private List<PurchaseSalesExpensesDTO> purchaseSalesExpensesDTOList;
}
